package com.polaris.live.ui.main.adapter

import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.common.ext.dp
import com.polaris.live.databinding.AdapterPartyGameRankTypeBinding
import com.polaris.live.resp.back_resp.PartyGameResp
import com.polaris.live.utils.image.loadWejoyImage

/**
 * PartyGameRankTypeAdapter
 *
 * @author Created by 半仙 on 2024/3/18/018 11:52
 */
class PartyGameRankTypeAdapter :
    BaseBindingAdapter<AdapterPartyGameRankTypeBinding, PartyGameResp>() {

    private var mSelectPosition = 0
    override fun convert(
        holder: VBViewHolder<AdapterPartyGameRankTypeBinding>,
        item: PartyGameResp,
    ) {
        holder.vb.apply {
            Glide.with(context)
                .loadWejoyImage(item.rankIcon)
                .transform(RoundedCorners(8.dp))
                .into(partyGameRankTypeImg)

            if (mSelectPosition == holder.absoluteAdapterPosition) {
                root.alpha = 1.0f
            } else {
                root.alpha = 0.3f
            }
        }
    }

    fun setSelect(position: Int) {
        mSelectPosition = position
        notifyDataSetChanged()
    }
}